﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MyWebPagesStarterKit.Controls;
using MyWebPagesStarterKit;

public partial class EasyControls_SearchForm : System.Web.UI.UserControl
{
    private string text;
    protected void Page_Load(object sender, EventArgs e)
    {
      
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        gvResults.Visible = true;
    }

    protected void Page_PreRender(object sender, EventArgs e)
    {
        //txtSearch.Focus();
        if (HttpContext.Current.Request["keyword"] != null)
        {
            text = HttpContext.Current.Request["keyword"];
        }
        else
        {
            text = txtSearch.Text;
        }

        //Response.Write(HttpContext.Current.Request["keyword"]);
        gvResults.DataSource = WebSite.GetInstance().Search(text.Trim());
        gvResults.DataBind();
        locNoresults.Visible = (gvResults.Rows.Count == 0);
       
    }
}
